//
//  MK_LivingRoom_ImageView.m
//  miku直播
//
//  Created by 杨尚达 on 2017/7/27.
//  Copyright © 2017年 杨尚达. All rights reserved.
//

#import "MK_LivingRoom_ImageView.h"

@implementation MK_LivingRoom_ImageView

-(void)awakeFromNib{
    [super awakeFromNib];
    [self setUpUI];
}

///初始化界面
-(void)setUpUI{
    
    CAGradientLayer* nameLayer = [[CAGradientLayer alloc]init];
    nameLayer.frame = CGRectMake(0, self.height-10, self.width, 10);
    [self.layer addSublayer:nameLayer];
    
    nameLayer.colors =  @[(__bridge id)[UIColor blackColor].CGColor, (__bridge id)[UIColor clearColor].CGColor];;
    nameLayer.startPoint = CGPointMake(0, 1);
    nameLayer.endPoint = CGPointMake(0, 0);
    nameLayer.locations = @[@0.0,@1.0];
    
    CAGradientLayer* numLayer = [[CAGradientLayer alloc]init];
    numLayer.frame = CGRectMake(self.width*0.5, 0, self.width*0.5, 10);
    [self.layer addSublayer:numLayer];
    
    numLayer.colors =  @[(__bridge id)[UIColor blackColor].CGColor, (__bridge id)[UIColor clearColor].CGColor];;
    numLayer.startPoint = CGPointMake(1, 0);
    numLayer.endPoint = CGPointMake(0, 0);
    numLayer.locations = @[@0.0,@1.0];
    
    UIButton* nameBu = [UIButton new];
    nameBu.userInteractionEnabled = NO;
    nameBu.imageView.contentMode = UIViewContentModeScaleAspectFit;
    [nameBu setImage:[UIImage imageNamed:@"icon_person"] forState:UIControlStateNormal];
    nameBu.titleLabel.font = [UIFont systemFontOfSize:10];
    [self addSubview:nameBu];
    [nameBu mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.right.offset(-8);
        make.height.equalTo(@10);
    }];
    _nameButton = nameBu;
    
    UIButton* numBu = [UIButton new];
    numBu.userInteractionEnabled = NO;
    numBu.titleLabel.font = [UIFont systemFontOfSize:10];
    numBu.imageView.contentMode = UIViewContentModeScaleAspectFit;
    [numBu setImage:[UIImage imageNamed:@"icon_looking"] forState:UIControlStateNormal];
    [self addSubview:numBu];
    [numBu mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.right.offset(-8);
        make.height.equalTo(@10);
    }];
    _numButton = numBu;
    
    self.layer.cornerRadius = 5;
    self.layer.masksToBounds = YES;
    self.userInteractionEnabled = YES;
    
    UIButton* bu = [UIButton new];
    bu.frame = self.bounds;
    [self addSubview:bu];
    [bu addTarget:self action:@selector(clickImageView:) forControlEvents:UIControlEventTouchUpInside];
}

-(void)clickImageView:(UIButton*)sender{
    [[NSNotificationCenter defaultCenter] postNotificationName:Notification_ClickLivingRoomModel object:self.model];
}

@end
